<?php
/**
 * Date: 2024.8
 * Author: kahn
 * 打折促销
 */
use config\Response;
use models\vip\SaleModel;
use models\vip\UserModel as VipUserModel;

class SaleController extends  Controller {

    /**
     * @return void
     */
    public function listAction(): void
    {

        $list = SaleModel::list();

        $this->_response(Response::SUCCESS, ['list'=>$list]);
    }

    /**
     * @return void
     */
    public function isvipAction(): void
    {
        $vip = VipUserModel::field('vipTime')
            ->where('userId',$this->userId)
            ->where('vipTime','>', time())
            ->where('status',1)
            ->findOrEmpty();

        $this->_response(Response::SUCCESS, ['vip'=>$vip->isEmpty() ? 0 : (int)($vip->vipTime > time())]);
    }

}